import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _class, _class2;

import React from 'react';
import { Form, Select, Modal } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
var formLayout = {
  labelCol: {
    span: 5
  },
  wrapperCol: {
    span: 15
  }
};
var ClearLogsDrawer = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec3 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(ClearLogsDrawer, _React$Component);

  var _super = _createSuper(ClearLogsDrawer);

  function ClearLogsDrawer() {
    _classCallCheck(this, ClearLogsDrawer);

    return _super.apply(this, arguments);
  }

  _createClass(ClearLogsDrawer, [{
    key: "handleCancel",
    value: function handleCancel() {
      var _this$props = this.props,
          form = _this$props.form,
          _this$props$onCancel = _this$props.onCancel,
          onCancel = _this$props$onCancel === void 0 ? function (e) {
        return e;
      } : _this$props$onCancel;
      form.resetFields();
      onCancel();
    }
  }, {
    key: "handleOk",
    value: function handleOk() {
      var _this$props2 = this.props,
          form = _this$props2.form,
          onOk = _this$props2.onOk;
      form.validateFields(function (err, fieldsValue) {
        if (!err) {
          onOk(fieldsValue);
        }
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props3 = this.props,
          form = _this$props3.form,
          title = _this$props3.title,
          modalVisible = _this$props3.modalVisible,
          loading = _this$props3.loading,
          _this$props3$clearTyp = _this$props3.clearTypeList,
          clearTypeList = _this$props3$clearTyp === void 0 ? [] : _this$props3$clearTyp;
      var getFieldDecorator = form.getFieldDecorator;
      return /*#__PURE__*/React.createElement(Modal, {
        destroyOnClose: true,
        title: title,
        visible: modalVisible,
        confirmLoading: loading,
        onCancel: this.handleCancel,
        onOk: this.handleOk
      }, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Form.Item, Object.assign({
        label: intl.get('cpfm.login.view.message.clearType').d('类型')
      }, formLayout), getFieldDecorator('clearType', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cpfm.login.view.message.clearType').d('类型')
          })
        }]
      })( /*#__PURE__*/React.createElement(Select, {
        style: {
          width: '100%'
        }
      }, clearTypeList.map(function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          key: item.value,
          value: item.value
        }, item.meaning);
      }))))));
    }
  }]);

  return ClearLogsDrawer;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "handleCancel", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCancel"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleOk", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "handleOk"), _class2.prototype)), _class2)) || _class);
export { ClearLogsDrawer as default };